package com.aica.controller;


import com.aica.service.PunchInRecordService;
import com.aica.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author by
 * @since 2021-07-20
 */
@RestController
@RequestMapping("/punchInRecord")
@PreAuthorize("isAuthenticated()")
public class PunchInRecordController {

    @Autowired
    private PunchInRecordService punchInRecordService;

    @PostMapping(value = "/rise")
    public ResultVo<Object> rise(
            UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken){
        return punchInRecordService.rise(usernamePasswordAuthenticationToken);
    }

    @PostMapping(value = "/sleep")
    public ResultVo<Object> sleep(
            UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken){
        return punchInRecordService.sleep(usernamePasswordAuthenticationToken);
    }

    @GetMapping(value = "/history")
    public ResultVo<Object> history(
            UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken){
        return punchInRecordService.history(usernamePasswordAuthenticationToken);
    }

}

